﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<WebHoiChoMuaBan.Models.MemberList>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Danh sách thành viên mới
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="HeadHolder" runat="server">
    <%
        ArrayList lstError = (ArrayList)Session["lstError"];
        if (lstError != null && lstError.Count > 0)
        {
    %>
    <div class="ui-corner-all error-panel">
        <ul>
            <%
foreach (var item in lstError)
{
    Response.Write("<li>" + item + "</li>");
}
Session["lstError"] = null;
            %>
        </ul>
    </div>
    <%
}
    %>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
    <div class="ButtonFunction">
        <a href="#" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary"
            title="" onclick="return showAddUpPointDialog('Hãy nhập số điểm cộng thêm', 'frmNewMember')">
            <span class="ui-button-icon-primary ui-icon ui-icon-plus "></span><span class="ui-button-text">
                Cộng điểm</span> </a><a href="#" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary"
                    title="" onclick="return showSubtractUpPointDialog('Hãy nhập số điểm cần trừ', 'frmNewMember')">
                    <span class="ui-button-icon-primary ui-icon ui-icon-minus "></span><span class="ui-button-text">
                        Trừ điểm</span> </a><a href="#" onclick="deleteMember()" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary"
                            title=""><span class="ui-button-icon-primary ui-icon ui-icon-cancel "></span><span
                                class="ui-button-text">Xóa</span> </a><a href="#" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary modalInput"
                                    rel=".prompt" title=""><span class="ui-button-icon-primary ui-icon ui-icon-mail-closed ">
                                    </span><span class="ui-button-text">Gửi email</span>
        </a>
    </div>
    <div class="Pagging">
        <form method="get" action="<%=Request.Path %>" name="frmPagingUp">
        <% 
            if (Model.TotalPages > 1)
            {
                if (Model.CurrentPage > 1)
                {
        %>
        <a href="?page=<%=Model.CurrentPage-1 %>">Trang trước</a>
        <%
}
        %>
        <select name="page" onchange="frmPagingUp.submit()">
            <%
                for (int i = 1; i <= Model.TotalPages; i++)
                {
                    if (i == Model.CurrentPage)
                    {
            %>
            <option value="<%=i %>" selected="selected">
                <%=i%></option>
            <%
}
                    else
                    {
            %>
            <option value="<%=i %>">
                <%=i%></option>
            <%
                }
                }
            %>
        </select>
        <%
            if (Model.CurrentPage < Model.TotalPages)
            {
        %>
        <a href="?page=<%=Model.CurrentPage+1 %>">Trang sau</a>
        <%
            }
            } //if (Model.TotalPages > 1)
        %>
        </form>
    </div>
    <div class="Clear">
        &nbsp;</div>
    <script type="text/javascript">
        function clearAllRadios(obj) {
            var input = document.getElementsByTagName("input");
            for (var i = 0; i < input.length; i++) {
                if (input[i].checked) input[i].checked = false;
            }
            obj.checked = true;
            //            $(document).ready(function () {
            //                $('.changeMemberType' + obj.value).removeClass('hidden');
            //            });
        }
        //        function ChangeFunction(obj, id) {

        //            $.ajax({
        //                type: "POST",
        //                url: "/Member/ChangeMemberType",
        //                data: "id=" + id + "&memberType=" + obj.value,
        //                success: function (result) {
        //                    window.location.reload(true);
        //                },
        //                error: function (req, status, error) {
        //                    alert("Sorry! We could not receive your feedback at this time.");
        //                }
        //            });
        //        }
    </script>
    <form method="post" action="" id="frmNewMember">
    <input type="hidden" id="inputNumber" name="inputNumber" />
    <table border="0px" cellpadding="3px" cellspacing="0px" width="100%">
        <tr>
            <th width="10px">
                <input id="cbSelectAllMem" type="checkbox" />
            </th>
            <th width="250px" colspan="2">
                Thành viên
            </th>
            <th>
                Điện thoại
            </th>
            <th>
                Điểm up
            </th>
            <th>
                Nổi bật
            </th>
            <th>
                Trang cá nhân
            </th>
            <th>
                Loại TV
            </th>
            <th>
                Active
            </th>
        </tr>
        <%
            foreach (var mem in Model.Members)
            { 
        %>
        <tr>
            <td>
                <input name="selectedMem" value="<%=mem.MemId %>" onclick='clearAllRadios(this)'
                    type="checkbox" />
            </td>
            <td width="20px">
                <center>
                    <img src="../../../Content/Images/Upload/<%=mem.MemAvatar %>" alt="" width="50" height="50" />
                </center>
            </td>
            <td>
                <center>
                    <div class="Header">
                        <%=mem.MemFullname %></div>
                    <div class="Description">
                        <%=mem.MemEmail %></div>
                </center>
            </td>
            <td class="Header">
                <center>
                    <%=mem.MemCellPhone %></center>
            </td>
            <td class="Header">
                <center>
                    <%=mem.MemUpPoint %></center>
            </td>
            <td class="Header">
                <center>
                    <%
                        string nicon, nmsg, nactionUrl;
               
                        if (mem.isHotMember == 1)
                        {
                            nicon = "ui-icon-check";
                            nmsg = "Đang nổi bật! Nhấn nút để hủy thiết lập";
                            nactionUrl = "UnHotMember";
                        }
                        else
                        {
                            nicon = "ui-icon-locked";
                            nmsg = "Đang không nổi bật. Hãy nhấn nút để Kích hoạt";
                            nactionUrl = "HotMember";
                        }
                    %>
                    <a href="/Admin/Member/<%=nactionUrl %>?id=<%=mem.MemId %>" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only"
                        title="<%=nmsg %>"><span class="ui-button-icon-primary ui-icon <%=nicon %> "></span>
                        <span class="ui-button-text">Button with icon only</span> </a>
                </center>
            </td>
            <td class="Header">
                <center>
                    <a target="_blank" href="/GianHang/<%=mem.MemId %>">Trang profile</a></center>
            </td>
            <td>
                <center>
                    <div>
                        <%=mem.MemberType.MemTypeName %>
                    </div>
                    <%--     <div class="hidden changeMemberType<%=mem.MemId %>">
                        <select onchange="ChangeFunction(this,<%=mem.MemId %>)">
                            <option value="1">Thường</option>
                            <option value="2">Đồng</option>
                            <option value="3">Bạc</option>
                            <option value="4">Vàng</option>
                        </select>
                    </div>--%>
                </center>
            </td>
            <td>
                <center>
                    <%
                        string icon, msg, actionUrl;
                        if (mem.MemStatus == (char?)WebHoiChoMuaBan.Models.Member.Status.Active)
                        {
                            icon = "ui-icon-check";
                            msg = "Đang kích hoạt. Hãy nhấn nút để Khóa";
                            actionUrl = "LockMember";
                        }
                        else
                        {
                            icon = "ui-icon-locked";
                            msg = "Đang bị khóa. Hãy nhấn nút để Kích hoạt";
                            actionUrl = "ActivateMember";
                        }
                    %>
                    <a href="/Admin/Member/<%=actionUrl %>?id=<%=mem.MemId %>" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-icon-only"
                        title="<%=msg %>"><span class="ui-button-icon-primary ui-icon <%=icon %> "></span>
                        <span class="ui-button-text">Button with icon only</span> </a>
                </center>
            </td>
        </tr>
        <%
            }
        %>
    </table>
    </form>
    <div class="modal prompt">
        <h2>
            Soạn nội dung Email</h2>
        <!-- input form. you can press enter too -->
        <%--  <form action="<%= Url.Action("Member","SendMailMember") %>" method="post" enctype="multipart/form-data">--%>
        <div id="ModalLoader">
        </div>
        <input type="text" id="ModalID" name="ModalID" class="ModalID hidden" />
        <textarea cols="40" rows="10" id="ModalNoiDung" name="ModalNoiDung" class="ModalNoiDung"></textarea>
        <br />
        <center>
            <button type="submit" onclick="sendMailMember()">
                OK
            </button>
            <button type="button" class="close">
                Cancel
            </button>
        </center>
        <%--  </form>--%>
        <br />
    </div>
    <br />
    <div class="ButtonFunction">
        <a href="#" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary"
            title="" onclick="return showAddUpPointDialog('Hãy nhập số điểm cộng thêm', 'frmNewMember')">
            <span class="ui-button-icon-primary ui-icon ui-icon-plus "></span><span class="ui-button-text">
                Cộng điểm</span> </a><a href="#" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary"
                    title="" onclick="return showSubtractUpPointDialog('Hãy nhập số điểm cần trừ', 'frmNewMember')">
                    <span class="ui-button-icon-primary ui-icon ui-icon-minus "></span><span class="ui-button-text">
                        Trừ điểm</span> </a><a href="#" onclick="deleteMember()" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary"
                            title=""><span class="ui-button-icon-primary ui-icon ui-icon-cancel "></span><span
                                class="ui-button-text">Xóa</span> </a><a href="#" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary modalInput"
                                    rel=".prompt" title=""><span class="ui-button-icon-primary ui-icon ui-icon-mail-closed ">
                                    </span><span class="ui-button-text">Gửi email</span>
        </a>
    </div>
    <div class="Pagging">
        <form method="get" action="<%=Request.Path %>" name="frmPagingUp2">
        <% 
            if (Model.TotalPages > 1)
            {
                if (Model.CurrentPage > 1)
                {
        %>
        <a href="?page=<%=Model.CurrentPage-1 %>">Trang trước</a>
        <%
}
        %>
        <select name="page" onchange="frmPagingUp2.submit()">
            <%
                for (int i = 1; i <= Model.TotalPages; i++)
                {
                    if (i == Model.CurrentPage)
                    {
            %>
            <option value="<%=i %>" selected="selected">
                <%=i%></option>
            <%
}
                    else
                    {
            %>
            <option value="<%=i %>">
                <%=i%></option>
            <%
                }
                }
            %>
        </select>
        <%
            if (Model.CurrentPage < Model.TotalPages)
            {
        %>
        <a href="?page=<%=Model.CurrentPage+1 %>">Trang sau</a>
        <%
            }
            } //if (Model.TotalPages > 1)
        %>
        </form>
    </div>
</asp:Content>
